struct Solution {}

fn main() {}

impl Solution {
    pub fn is_ugly(n: i32) -> bool {
        if n <= 0 {
            return false;
        }

        let mut num = n;
        while num > 1 {
            if num % 5 == 0 {
                num /= 5;
                continue;
            }
            if num % 3 == 0 {
                num /= 3;
                continue;
            }
            if num % 2 == 0 {
                num /= 2;
                continue;
            }
            return false;
        }
        true
    }
}